package com.lian.springboot.controller;

import com.lian.springboot.entity.User;
import com.lian.springboot.mapper.UserMapper;
import com.lian.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private UserService userService;
    @DeleteMapping("/id")
    public Integer delete(@PathVariable Integer id){
        return userMapper.deleteByID(id);
    }

    @PostMapping
    public Integer save(@RequestBody User user ){
        return  userService.save(user);//新增或者更新
    }


    @GetMapping
    public List<User> index(){
        return userMapper.findAll();    //查询
    }

    @GetMapping("/page") //接口路径 user/page?pageNum=1&pageSize=10  // RequestParm  接收
    public Integer paging(@RequestParam Integer pageNum,@RequestParam Integer pageSize){
    return 0;
    }



}

